package com.cloudtf.klsz.live;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import com.cloudtf.klsz.live.PermissionsUtils.PermissionsList;
import com.cloudtf.klsz.live.PermissionsUtils.PermissionsUtils;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private Button mPushBtn;
    private Button mPlayBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //动态权限申请
        PermissionsUtils.getInstance().chekPermissions(this, PermissionsList.permissions, permissionsResult);
        setContentView(R.layout.activity_main);
        mPushBtn = (Button) findViewById(R.id.push_stream_btn);
        mPlayBtn = (Button) findViewById(R.id.play_stream_btn);
        mPushBtn.setOnClickListener(this);
        mPlayBtn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.push_stream_btn:
                startActivity(new Intent(this, CameraActivity.class));
                break;
            case R.id.play_stream_btn:
                startActivity(new Intent(this, PlayerActivity.class));
                break;
        }
    }

    //创建监听权限的接口对象
    PermissionsUtils.IPermissionsResult permissionsResult = new PermissionsUtils.IPermissionsResult() {
        @Override
        public void passPermissons() {
//            Toast.makeText(getParent(), "权限通过，可以做其他事情!", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void forbitPermissons() {
//            finish();
//            Toast.makeText(getParent(), "权限不通过!", Toast.LENGTH_SHORT).show();
        }
    };
}